home *** CD-ROM | disk | FTP | other *** search
/ World of Sound / World of Sound.iso / utils / modplayers / tracker / extern.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  8.0 KB  |  406 lines

  1. /* extern.h */
  2.  
  3. /* $Id: extern.h,v 3.13 1993/11/17 15:31:16 espie Exp espie $
  4.  * $Log: extern.h,v $
  5.  * Revision 3.13  1993/11/17  15:31:16  espie
  6.  * *** empty log message ***
  7.  *
  8.  * Revision 3.12  1993/11/11  20:00:03  espie
  9.  * Amiga support.
  10.  *
  11.  * Revision 3.10  1993/07/18  10:39:44  espie
  12.  * Added pid, fork, show.
  13.  *
  14.  * Revision 3.8  1993/01/15  14:00:28  espie
  15.  * Added bg/fg test.
  16.  *
  17.  * Revision 3.7  1992/12/03  15:00:50  espie
  18.  * stty_sane.
  19.  *
  20.  * Revision 3.5  1992/11/24  10:51:19  espie
  21.  * New audio functions.
  22.  *
  23.  * Revision 3.2  1992/11/22  17:20:01  espie
  24.  * Simplified delay_pattern.
  25.  *
  26.  * Revision 3.1  1992/11/19  20:44:47  espie
  27.  * Protracker commands.
  28.  *
  29.  * Revision 3.0  1992/11/18  16:08:05  espie
  30.  * New release.
  31.  *
  32.  * Revision 2.19  1992/11/17  17:06:25  espie
  33.  * Lots of new functions to account for new interface.
  34.  * open_file support.
  35.  * Separated mix/stereo stuff.
  36.  * Added possibility to get back to MONO for the sgi.
  37.  * Added stereo capabilities to the indigo version.
  38.  * Added some new song types to automatize the choice process.
  39.  * Moved resampling to audio, added prototype.
  40.  * Added SAMPLE_FAULT, for trying to play
  41.  * a note without a sample (not really an error).
  42.  *
  43.  * Revision 1.7  1991/11/08  14:25:55  espie
  44.  * Modified audio prototype so that you can change
  45.  * frequency.
  46.  * Added prototype for release_song.
  47.  * Added arpeggio effect.
  48.  * Added entries for new effects.
  49.  * Added entries for commands.c.
  50.  */
  51.  
  52.  
  53.  
  54.  
  55.  
  56. /* audio.c */
  57. #define ACCURACY 12
  58. #define fix_to_int(x) ((x) >> ACCURACY)
  59. #define int_to_fix(x) ((x) << ACCURACY)
  60.  
  61. /* init_tables(oversample, frequency, chan):
  62.  * precomputes the step_table and the pitch_table
  63.  * according to the desired oversample and frequency.
  64.  * This is static, you can call it again whenever you want.
  65.  * adjusting current parameters of channel if needed.
  66.  */
  67. XT void init_tables();
  68.  
  69. /* resample(chan, oversample, number):
  70.  * send number samples out computed according
  71.  * to the current state of chan[0:NUMBER_CHANNELS],
  72.  * and oversample.
  73.  */
  74. XT void resample();
  75.  
  76. /* play_note(au, samp, pitch)
  77.  * set audio channel au to play samp at pitch
  78.  */
  79. XT void play_note();
  80.  
  81. /* set_play_pitch(audio, pitch):
  82.  * set channel audio to play at pitch pitch
  83.  */
  84. XT void set_play_pitch();
  85.  
  86. /* set_play_volume(audio, volume):
  87.  * set channel audio to play at volume volume
  88.  */
  89. XT void set_play_volume();
  90.  
  91. /* set_play_position(audio, pos):
  92.  * set position in sample for current channel at given offset
  93.  */
  94. XT void set_play_position();
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. /* automaton.c */
  102. /* init_automaton(a, song):
  103.  * put the automaton a in the right state to play song.
  104.  */
  105. XT void init_automaton();
  106. /* next_tick(a):
  107.  * set up everything for the next tick.
  108.  */
  109. XT void next_tick();
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. /* commands.c */
  118. /* init_effects(): sets up all data for the effects */
  119. XT void init_effects();
  120. /* do_nothing: this is the default behavior for an effect.
  121.  */
  122. XT void do_nothing();
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. /* dump_song */
  132. /* dump_song(s): 
  133.  * displays some information pertinent to the given 
  134.  * song s.
  135.  */
  136. XT void dump_song();
  137.  
  138.  
  139. XT void init_display();
  140.  
  141.  
  142.  
  143.  
  144.  
  145. /* getopt.c */
  146. /* n = getopt(argc, argv, options):
  147.  * try to parse options out of argv, using
  148.  * ways similar to standard getopt
  149.  */
  150. XT int getopt();
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. /* main.c */
  158. XT int pid, forked;
  159. #define OLD 0
  160. #define NEW 1
  161. /* special new type: for when we try to read it as both types.
  162.  */
  163. #define BOTH 2
  164. /* special type: does not check the signature */
  165. #define NEW_NO_CHECK 3
  166.  
  167.  
  168. /* error types. Everything is centralized,
  169.  * and we check in some places (see read, player and str32)
  170.  * that there was no error. Additionnally signal traps work
  171.  * that way too.
  172.  */
  173.  
  174. /* normal state */
  175. #define NONE 0  
  176. /* read error */
  177. #define FILE_TOO_SHORT 1
  178. #define CORRUPT_FILE 2
  179. /* trap error: goto next song right now */
  180. #define NEXT_SONG 3
  181. /* run time problem */
  182. #define FAULT 4
  183. /* the song has ended */
  184. #define ENDED 5
  185. /* unrecoverable problem: typically, trying to 
  186.  * jump to nowhere land.
  187.  */
  188. #define UNRECOVERABLE 6
  189. /* Missing sample. Very common error, not too serious. */
  190. #define SAMPLE_FAULT 7
  191. /* New */
  192. #define PREVIOUS_SONG 8
  193. XT int error;
  194.  
  195. /* end_all(): faaaast exit */
  196. XT void end_all();
  197.  
  198.  
  199.  
  200.  
  201. /* notes.c */
  202. #define NUMBER_NOTES 120
  203. #define NUMBER_FINETUNES 17
  204. XT int pitch_table[NUMBER_NOTES][NUMBER_FINETUNES];
  205. XT char note_name[NUMBER_NOTES][4];
  206. /* create_notes_table():
  207.  * build the correspondance pitch -> note
  208.  */
  209. XT void create_notes_table();
  210. /* note = find_note(pitch):
  211.  * find note corresponding to a given pitch
  212.  */
  213. XT int find_note();
  214. /* oldtranspose = transpose_song(song, newtranspose):
  215.  * tranpose song to a new pitch
  216.  */
  217. XT int transpose_song();
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224. /* open.c */
  225. /* handle = open_file(filename, mode, path):
  226.  * transparently open a compressed file.
  227.  */
  228. XT FILE *open_file();
  229.  
  230. /* close_file(handle):
  231.  * close a file that was opened with open_file.
  232.  */
  233. XT void close_file();
  234.  
  235.  
  236.  
  237. /* display.c */
  238. /* dump_event(ch, e, imask):
  239.  */
  240. XT void dump_event();
  241.  
  242. /* show
  243.  */
  244. XT BOOL show;
  245.  
  246.  
  247. /* player.c */
  248.  
  249. /* reset_note(ch, note, pitch):
  250.  * set channel ch to play note at pitch pitch
  251.  */
  252. XT void reset_note();
  253.  
  254. /* set_current_pitch(ch, pitch):
  255.  * set ch to play at pitch pitch
  256.  */
  257. XT void set_current_pitch();
  258.  
  259. /* set_current_volume(ch, volume):
  260.  * set channel ch to play at volume volume
  261.  */
  262. XT void set_current_volume();
  263.  
  264. /* set_position(ch, pos):
  265.  * set position in sample for current channel at given offset
  266.  */
  267. XT void set_position();
  268.  
  269. /* init_player(oversample, frequency):
  270.  * sets up the player for a given oversample and
  271.  * output frequency.
  272.  * Note: we can call init_player again to change oversample and
  273.  * frequency.
  274.  */
  275. XT void init_player();
  276.  
  277. /* play_song(song, pref):
  278.  * plays the song according to the current pref.
  279.  */
  280. XT void play_song();
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288. /* read.c */
  289. /* s = read_song(f, type):
  290.  * tries to read f as a song of type NEW/OLD.
  291.  * returns NULL (and an error) if it doesn't work.
  292.  * Returns a dynamic song structure if successful.
  293.  */
  294. XT struct song *read_song();
  295.  
  296. /* release_song(s):
  297.  * release all the memory song occupies.
  298.  */
  299. XT void release_song();
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307. /* setup_audio.c */
  308. /* setup_audio(ask_freq, stereo, oversample, sync):
  309.  * setup the audio output with these values 
  310.  */
  311. XT void setup_audio();
  312. /* do_close_audio():
  313.  * close audio only if needed
  314.  */
  315. XT void do_close_audio();
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. /* xxx_audio.c */
  324. /* frequency = open_audio(f, s):
  325.  * try to open audio with a sampling rate of f, and eventually stereo.
  326.  * We get the real frequency back. If we ask for 0, we
  327.  * get the ``preferred'' frequency.
  328.  * Note: we have to close_audio() before we can open_audio() again.
  329.  * Note: even if we don't ask for stereo, we still have to give a
  330.  * right and left sample.
  331.  */
  332. XT int open_audio();
  333. /* close_audio():
  334.  * returns the audio to the system control, doing necessary
  335.  * cleanup
  336.  */
  337. XT void close_audio();
  338. /* set_mix(percent): set mix channels level.
  339.  * 0: spatial stereo. 100: mono.
  340.  */
  341. XT void set_mix();
  342. /* output_samples(l, r): outputs a pair of stereo samples.
  343.  * Samples are 15 bits signed.
  344.  */
  345. XT void output_samples();
  346. /* flush_buffer(): call from time to time, because buffering
  347.  * is done by the program to get better (?) performance.
  348.  */
  349. XT void flush_buffer();
  350. /* discard_buffer(): try to get rid of the buffer contents
  351.  */
  352. XT void discard_buffer();
  353. /* new_freq = update_frequency():
  354.  * if !0, frequency changed and playing should be updated accordingly
  355.  */
  356. XT int update_frequency();
  357. /* set_synchro(bool):
  358.  * try to synchronize audio output by using a smaller buffer
  359.  */
  360. XT void set_synchro();
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368. /* termio.c */
  369. /* nonblocking_io():
  370.  * try to setup the keyboard to non blocking io
  371.  */
  372. XT void nonblocking_io();
  373. XT void sane_tty();
  374. /* may_getchar():
  375.  * return EOF, or a char if available
  376.  */
  377. XT int may_getchar();
  378. /* run_in_fg():
  379.  * try to decide whether or not we're currently running in the foreground.
  380.  */
  381. XT BOOL run_in_fg();
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389. /* tools.c */
  390. /* v = read_env(name, default):
  391.  * read a scalar value in the environment
  392.  */
  393. XT int read_env();
  394.  
  395. #ifdef AMIGA
  396. XT FILE *popen(char *command, char *mode);
  397. XT void pclose(FILE *f);
  398. #else
  399. #define alloc_sample(len)        calloc(len, 1)
  400. #define free_sample(sample)        free(sample)
  401. #endif
  402.  
  403.  
  404. XT void reset_channels();
  405. XT struct audio_channel *new_channel();
  406.